package daobeauty.interceptor.invoke.fill;

import java.util.Collection;

import org.hibernate.Query;

/**
 * Fills the parameters of a query from a collection, which is the first parameter.
 * 
 * @author M.Serhat Cinar
 *
 */
public class CollectionQueryFill implements ParameterFillStrategy {

	public void fillParameters(Object q, Object[] parameters) {
		final Query query = (Query) q;
		final Collection collection = (Collection) parameters[0];
		int i=0;
		for (Object parameter:collection){
			query.setParameter(i++, parameter);
		}
	}
	
	public String toString(){
		return "collection";
	}

}
